/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.agilelang.editor.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import org.agilelang.editor.ViewFrame;
import org.agilelang.editor.dialog.DlgNewProject;
import org.agilelang.editor.dialog.DlgNewProject3;
import org.agilelang.editor.tool.InfoProject;

/**
 *
 * @author RODERICK
 */
public class FileNewProject implements ActionListener {

    ViewFrame frame;

    public FileNewProject(ViewFrame frame) {
        this.frame = frame;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        DlgNewProject3 dlg = new DlgNewProject3(new javax.swing.JFrame(), true);
        dlg.setLocationRelativeTo(null);
        dlg.setVisible(true);
        if (dlg.isStatus()) {
            String app_path = dlg.getTxtPath();// + File.separator + dlg.getName();
            frame.setPathProject(app_path);
            File folder = new File(app_path);
            if (!folder.exists()) {
                folder.mkdirs();
                File folder2 = new File(app_path);
                folder2.exists();
                System.out.println("createDirectory : " + folder.getAbsolutePath());
            }
            File folder2 = new File(app_path + File.separator + "static");
            folder2.mkdirs();

            File folder3 = new File(app_path + File.separator + "tmpl");
            folder3.mkdirs();
            
            File folder4 = new File(app_path + File.separator + "tmp");
            folder4.mkdirs();

            File folder5 = new File(app_path + File.separator + "config");
            folder5.mkdirs();
            
            File folder6 = new File(app_path + File.separator + "source");
            folder6.mkdirs();

            InfoProject project = new InfoProject();
            project.name = dlg.getName();
            project.save(app_path);
            frame.setProject(project);
            frame.newproject();

        }
    }
}
